
all: clean  A6 
	
A6:
	bison interpreterext.ypp # to create C++ file interpreterext.tab.cpp
	bison -d programext.y # to create header file program.tab.h for lexer
	flex programext.l
	gcc -c lex.yy.c # create the object file lex.yy.o
	g++ interpreterext.tab.cpp programext.cpp lex.yy.o -o interpreterext | more # create the object file lex.yy.o 

parsetrace: 
	bison -d -t parsetrace.y # to create header file parsetrace.tab.h for lexer
	flex parsetrace.l
	cc -o $@ parsetrace.tab.c lex.yy.c -lfl

parseclean: 
	bison -d parseclean.y # to create header file parseclean.tab.h for lexer
	flex parseclean.l
	cc -o $@ parseclean.tab.c lex.yy.c -lfl

parsecleantest: parseclean
	./parseclean < samples/add1-by-curry.p 
	./parseclean < samples/add.p 
	./parseclean < samples/addr.p 
	./parseclean < samples/assign-proc.p 
	./parseclean < samples/assign-proc-and-call.p 
	./parseclean < samples/ccc.p 
	./parseclean < samples/ccc-oneline.p 
	./parseclean < samples/ccc-oper.p 
	./parseclean < samples/ccc-oper-oneline.p 
	./parseclean < samples/curry.p 
	./parseclean < samples/fact.p 
	./parseclean < samples/factorial.p 
	./parseclean < samples/fact-unnamed.p 
	./parseclean < samples/if.p 
	./parseclean < samples/make-double-oper.p 
	./parseclean < samples/make-double-wrapper.p 
	./parseclean < samples/nested.p 
	./parseclean < samples/pg170-3-19.p 
	./parseclean < samples/samplefile.p 
	./parseclean < samples/scopetest.p 
	./parseclean < samples/scoping.p 
	./parseclean < samples/sepsteps.p 
	./parseclean < samples/sepstepstest.p 
	./parseclean < samples/sepstepstest2.p 
	./parseclean < samples/twostepa.p 
	./parseclean < samples/twostepb.p 
	./parseclean < samples/unnamed.p 
	./parseclean < samples/while.p 
	
clean:
	rm -rf *o 
	rm -rf *.tab.*
	rm -rf lex.yy.c
	rm -rf interpreterext
	rm -rf parse
	rm -rf parsetrace
	rm -rf parseclean
	rm -rf samples/actual/*

test: clean A6
#	./interpreterext < samples/add1-by-curry.p > samples/actual/add1-by-curry.txt
	./interpreterext < samples/add.p > samples/actual/add.txt
	./interpreterext < samples/addr.p > samples/actual/addr.txt
	./interpreterext < samples/assign-proc.p > samples/actual/assign-proc.txt
	./interpreterext < samples/assign-proc-and-call.p > samples/actual/assign-proc-and-call.txt
#	./interpreterext < samples/ccc.p > samples/actual/ccc.txt
#	./interpreterext < samples/ccc-oper.p > samples/actual/ccc-oper.txt 
#	./interpreterext < samples/curry.p > samples/actual/curry.txt
	./interpreterext < samples/fact.p > samples/actual/fact.txt
	./interpreterext < samples/factorial.p > samples/actual/factorial.txt
	./interpreterext < samples/if.p > samples/actual/if.txt
#	./interpreterext < samples/make-double-oper.p > samples/actual/make-double-oper.txt
#	./interpreterext < samples/make-double-wrapper.p > samples/actual/make-double-wrapper.txt
	./interpreterext < samples/nested.p > samples/actual/nested.txt
#	./interpreterext < samples/pg170-3-19.p > samples/actual/pg170-3-19.txt
	./interpreterext < samples/samplefile.p > samples/actual/samplefile.txt
	./interpreterext < samples/scopetest.p > samples/actual/scopetest.txt
#	./interpreterext < samples/scoping.p > samples/actual/scoping.txt
	./interpreterext < samples/sepsteps.p > samples/actual/sepsteps.txt
	./interpreterext < samples/sepstepstest.p > samples/actual/sepstepstest.txt
	./interpreterext < samples/sepstepstest2.p > samples/actual/sepstepstest2.txt
	./interpreterext < samples/twostepa.p > samples/actual/twostepa.txt
#	./interpreterext < samples/twostepb.p > samples/actual/twostepb.txt
#	./interpreterext < samples/unnamed.p > samples/actual/unnamed.txt
	./interpreterext < samples/while.p > samples/actual/while.txt
#	./interpreterext < samples/fact-unnamed.p > samples/actual/fact-unnamed.txt
#	./interpreterext < samples/ccc-oneline.p > samples/actual/ccc-oneline.txt
#	./interpreterext < samples/ccc-oper-oneline.p > samples/actual/ccc-oper-oneline.txt
#	diff -q  samples/expected/add1-by-curry.txt samples/actual/add1-by-curry.txt
	diff -q  samples/expected/add.txt samples/actual/add.txt
	diff -q  samples/expected/addr.txt samples/actual/addr.txt
	diff -q  samples/expected/assign-proc.txt samples/actual/assign-proc.txt
	diff -q  samples/expected/assign-proc-and-call.txt samples/actual/assign-proc-and-call.txt
#	diff -q  samples/expected/ccc.txt samples/actual/ccc.txt
#	diff -q  samples/expected/ccc-oper.txt samples/actual/ccc-oper.txt
#	diff -q  samples/expected/curry.txt samples/actual/curry.txt
	diff -q  samples/expected/fact.txt samples/actual/fact.txt
	diff -q  samples/expected/factorial.txt samples/actual/factorial.txt
	diff -q  samples/expected/if.txt samples/actual/if.txt
#	diff -q  samples/expected/make-double-oper.txt samples/actual/make-double-oper.txt
#	diff -q  samples/expected/make-double-wrapper.txt samples/actual/make-double-wrapper.txt
	diff -q  samples/expected/nested.txt samples/actual/nested.txt
#	diff -q  samples/expected/pg170-3-19.txt samples/actual/pg170-3-19.txt
	diff -q  samples/expected/samplefile.txt samples/actual/samplefile.txt
	diff -q  samples/expected/scopetest.txt samples/actual/scopetest.txt
#	diff -q  samples/expected/scoping.txt samples/actual/scoping.txt
	diff -q  samples/expected/sepsteps.txt samples/actual/sepsteps.txt
	diff -q  samples/expected/sepstepstest.txt samples/actual/sepstepstest.txt
	diff -q  samples/expected/sepstepstest2.txt samples/actual/sepstepstest2.txt
	diff -q  samples/expected/twostepa.txt samples/actual/twostepa.txt
#	diff -q  samples/expected/twostepb.txt samples/actual/twostepb.txt
#	diff -q  samples/expected/unnamed.txt samples/actual/unnamed.txt
	diff -q  samples/expected/while.txt samples/actual/while.txt
#	diff -q  samples/expected/fact-unnamed.txt samples/actual/fact-unnamed.txt
#	diff -q  samples/expected/ccc-oneline.txt samples/actual/ccc-oneline.txt
#	diff -q  samples/expected/ccc-oper-oneline.txt samples/actual/ccc-oper-oneline.txt
	
expected: clean A6
	rm -rf samples/expected/*
#	./interpreterext < samples/add1-by-curry.p > samples/expected/add1-by-curry.txt
	./interpreterext < samples/add.p > samples/expected/add.txt
	./interpreterext < samples/addr.p > samples/expected/addr.txt
	./interpreterext < samples/assign-proc.p > samples/expected/assign-proc.txt
	./interpreterext < samples/assign-proc-and-call.p > samples/expected/assign-proc-and-call.txt
#	./interpreterext < samples/ccc.p > samples/expected/ccc.txt
#	./interpreterext < samples/ccc-oper.p > samples/expected/ccc-oper.txt
#	./interpreterext < samples/curry.p > samples/expected/curry.txt
	./interpreterext < samples/fact.p > samples/expected/fact.txt
	./interpreterext < samples/factorial.p > samples/expected/factorial.txt
	./interpreterext < samples/if.p > samples/expected/if.txt
#	./interpreterext < samples/make-double-oper.p > samples/expected/make-double-oper.txt
#	./interpreterext < samples/make-double-wrapper.p > samples/expected/make-double-wrapper.txt
	./interpreterext < samples/nested.p > samples/expected/nested.txt
#	./interpreterext < samples/pg170-3-19.p > samples/expected/pg170-3-19.txt
	./interpreterext < samples/samplefile.p > samples/expected/samplefile.txt
	./interpreterext < samples/scopetest.p > samples/expected/scopetest.txt
#	./interpreterext < samples/scoping.p > samples/expected/scoping.txt
	./interpreterext < samples/sepsteps.p > samples/expected/sepsteps.txt
	./interpreterext < samples/sepstepstest.p > samples/expected/sepstepstest.txt
	./interpreterext < samples/sepstepstest2.p > samples/expected/sepstepstest2.txt
	./interpreterext < samples/twostepa.p > samples/expected/twostepa.txt
#	./interpreterext < samples/twostepb.p > samples/expected/twostepb.txt
#	./interpreterext < samples/unnamed.p > samples/expected/unnamed.txt
	./interpreterext < samples/while.p > samples/expected/while.txt
#	./interpreterext < samples/fact-unnamed.p > samples/expected/fact-unnamed.txt
#	./interpreterext < samples/ccc-oneline.p > samples/expected/ccc-oneline.txt
#	./interpreterext < samples/ccc-oper-oneline.p > samples/expected/ccc-oper-oneline.txt
